qui {
	capture program drop ccn_het_newsym_flexdelta
	local count=0
	local subsample = "$subsample"
	local modelname = "$modelname"
	foreach lhs in $LHSlist { 
		local controls="${CONTROLlist_`lhs'}"
		local beta_controls "${BETA_control_list}"
		local delta_controls "${DELTA_control_list}"
		foreach rhs in $RHSlist { 
			foreach robust in $robust_list {
				forvalues K=$K_list {
					noisily display "LHS=`lhs', RHS=`rhs', SE=`robust', K=`K', $S_DATE, $S_TIME"
					qui {
					local count=`count'+1
					matrix actual_estimates_mat = J(1,26,-9)
					mat colnames actual_estimates_mat = const_hettobit beta1_hettobit beta2_hettobit beta3_hettobit d_const_hettobit d_delta1_hettobit ///
						const_symm beta1_symm beta2_symm beta3_symm d_const_symm d_delta1_symm ///		
						const_hetuni beta1_hetuni beta2_hetuni beta3_hetuni d_const_hetuni d_delta1_hetuni ///
						const_none beta1_none beta2_none beta3_none ///
						cont_naive beta1_naive beta2_naive beta3_naive

					local rowcounter = 1
					local i = 1
					use "$datapath/003_cluster_`subsample'_`lhs'.dta", clear
					local control_length = 0
					foreach control of varlist `controls' {
						local control_length = `control_length' + 1
					}
					global control_length = `control_length'
					qui tab X_`K', generate(dumX_`K'_)
					
					*Het Tobit
					qui ccn_het_newsym_flexdelta het_tobit `K' `rhs' `lhs' `robust' "`controls'" het_tobit 1 "`beta_controls'" "`delta_controls'" 0
					matrix actual_estimates_mat[`rowcounter',1] = COEFFS[1,3] // constant
					matrix actual_estimates_mat[`rowcounter',2] = COEFFS[1,4] // hours
					matrix actual_estimates_mat[`rowcounter',3] = COEFFS[1,5] // afqt
					matrix actual_estimates_mat[`rowcounter',4] = COEFFS[1,6] // hrsafqt
					matrix actual_estimates_mat[`rowcounter',5] = COEFFS[1,1] // Delt constant
					matrix actual_estimates_mat[`rowcounter',6] = COEFFS[1,2] // Delt interaction

					*Symmetric;
					qui ccn_het_newsym_flexdelta symmetric `K' `rhs' `lhs' `robust' "`controls'" het_tobit 1 "`beta_controls'" "`delta_controls'" 0
					matrix actual_estimates_mat[`rowcounter',7] = COEFFS[1,3] // constant
					matrix actual_estimates_mat[`rowcounter',8] = COEFFS[1,4] // hours
					matrix actual_estimates_mat[`rowcounter',9] = COEFFS[1,5] // afqt
					matrix actual_estimates_mat[`rowcounter',10] = COEFFS[1,6] // hrsafqt
					matrix actual_estimates_mat[`rowcounter',11] = COEFFS[1,1] // Delt constant
					matrix actual_estimates_mat[`rowcounter',12] = COEFFS[1,2] // Delt interaction

					*Uniform
					qui ccn_het_newsym_flexdelta het_uniform `K' `rhs' `lhs' `robust' "`controls'" het_tobit 1 "`beta_controls'" "`delta_controls'" 0
					matrix actual_estimates_mat[`rowcounter',13] = COEFFS[1,3] // constant
					matrix actual_estimates_mat[`rowcounter',14] = COEFFS[1,4] // hours
					matrix actual_estimates_mat[`rowcounter',15] = COEFFS[1,5] // afqt
					matrix actual_estimates_mat[`rowcounter',16] = COEFFS[1,6] // hrsafqt
					matrix actual_estimates_mat[`rowcounter',17] = COEFFS[1,1] // Delt constant
					matrix actual_estimates_mat[`rowcounter',18] = COEFFS[1,2] // Delt interaction
					
					*No Controls
					qui ccn_het_newsym_flexdelta naiveN `K' `rhs' `lhs' `robust' "`controls'" het_tobit 1 "`beta_controls'" "`delta_controls'" 0
					matrix actual_estimates_mat[`rowcounter',19] = COEFFS[1,1] // constant
					matrix actual_estimates_mat[`rowcounter',20] = COEFFS[1,2] // hours
					matrix actual_estimates_mat[`rowcounter',21] = COEFFS[1,3] // afqt
					matrix actual_estimates_mat[`rowcounter',22] = COEFFS[1,4] // hrsafqt
					
					*Naive
					qui ccn_het_newsym_flexdelta naive `K' `rhs' `lhs' `robust' "`controls'" het_tobit 1 "`beta_controls'" "`delta_controls'" 0
					matrix actual_estimates_mat[`rowcounter',23] = COEFFS[1,1] // constant
					matrix actual_estimates_mat[`rowcounter',24] = COEFFS[1,2] // hours
					matrix actual_estimates_mat[`rowcounter',25] = COEFFS[1,3] // afqt
					matrix actual_estimates_mat[`rowcounter',26] = COEFFS[1,4] // hrsafqt


					local rowcounter = `rowcounter'+1
					local i = `i' + 1

					clear
					noisily matrix list actual_estimates_mat
					qui svmat actual_estimates_mat, names(col)
					gen LHS="`lhs'"
					gen RHS="`rhs'"
					gen Kcluster=`K'
					gen Robust="`robust'"
					save "$datapath/004_het_beta3_delta1_flex_delta_results_`subsample'_`modelname'_`lhs'_`robust'_K`K'.dta", replace
					}
				}
			}
		}			
	}

}
